
<!-- ▼ Main container -->
<div id="app-container" class="container order_all_order_list" myApp="Store_Order_List">
  <!--订单筛选-->
  <%= hidden_field_tag :authenticity_token, form_authenticity_token, id: 'js-ruiqu-store-orders-index' %>
  <div class="app">
    <div class="app-inner clearfix">
      <div class="app-init-container">
        <div class="app__content js-app-main page-trade-order">
          <div class="widget-list">

            <div class="js-list-filter-region clearfix">
              <div class="widget-list-filter">

              <%= render "check_form" %>

                <!--付款状态-->
                <!-- <%= render "order_status" %> -->
              </div>
            </div>
            <div class="ui-box">
              <div class="js-list-empty-region">
                <div>
                  <div class="widget-list-empty">
                    <table id="table">
                      <thead>
                        <th>单位</th>
                        <th>预订周期</th>
                        <th>总价：元</th>
                        <th>交易状态</th>
                        <th>操作</th>
                      </thead>
                      <tbody>
                        <% @store_orders.each do |order| %>
                          <%= render "item", order: order %>
                        <% end %>
                      </tbody>
                    </table>
                  </div>
                  <div class="js-list-footer-region ui-box">
                    <div class="widget-list-footer js-ms-order-list-pagination">
                      <!-- <%= render "pagination" %> -->
                    </div><!-- ▲ Main container -->
                  </div>
                  <%= paginate @store_orders %>
                </div>
              </div>
            </div>
            <div id="view-dialog" class="alert-body" data-order-no="">

              <div id="show" class="alert-container" style="margin-top: -260px;">
                <div class="alert-title"><span>查看订单</span><i class="close-btn">&#xe602</i></div>
                <div id="view-inputs" class="view-inputs">
                  <ul></ul>
                </div>
                <div class="buttons">
                  <button class="black-btn cancel-btn" id="view_close">确定</button>
                </div>
              </div>
            </div>
          </div>
        </div>
      </div>
      <%= render "dialog" %>
    </div>
  </div>
</div>

<script type="text/javascript">
  $("a.js-order-numero").on("click", function(e){
    e.preventDefault();
    var orderItemTemp = JST["ruiqu/store_orders/items"]
    var id = $(this).data("id");
    $.ajax({
      url: "/api/store_orders/"+ id,
      success: function(data){
        if(data.status){
          console.log(data.items);


          BootstrapDialog.show({
            title: "订单详情",
            message: orderItemTemp({items: data.items, remark: data.remark}),
            buttons: [{
                label: '确定',
                cssClass: 'btn-primary',
                action: function(dialogRef){
                    dialogRef.close();
                }
            }]
          });


        }else {
          showErrorView("服务器出错！")
        }
      }
    })

  })
</script>
